package com.nju.edu.android_app.callback;

import java.io.IOException;

import org.json.JSONObject;
import org.json.JSONTokener;

import android.os.Bundle;
import android.os.Message;

import com.nju.edu.android_app.MainActivity;
import com.weibo.sdk.android.WeiboException;
import com.weibo.sdk.android.net.RequestListener;

public class UserShowListener implements RequestListener{
	
	private MainActivity mainActivity;
	
	public UserShowListener(MainActivity mainActivity)
	{
		this.mainActivity=mainActivity;
	}

	@Override
	public void onComplete(String response) {
		// TODO Auto-generated method stub
		try {
			Message msg = new Message();
			Bundle bundle = new Bundle();
			JSONTokener jsonTokener = new JSONTokener(response);
			JSONObject user = (JSONObject) jsonTokener.nextValue();
			bundle.putString("name", user.getString("name"));
			msg.setData(bundle);
			mainActivity.showUserInfo.sendMessage(msg);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	@Override
	public void onIOException(IOException e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onError(WeiboException e) {
		// TODO Auto-generated method stub
		
	}

}
